package follow.juc.heima.day9;

import java.util.HashMap;
import java.util.Map;

public class Demo4ConcurrentHashMap3 {
    public static void main(String[] args) {
        final Map<String, Integer> count = new HashMap<>();

        for (int i=0;i<2000;i++){
            count.put("count"+i,1);
        }

        Runnable task1 = new Runnable(){

            @Override
            public void run() {
                for (int i=0;i<500;i++){
                    count.remove("count"+i);
                }

            }
        };


        Runnable task2 = new Runnable(){

            @Override
            public void run() {
                for (int i=1000;i<1500;i++){
                    count.remove("count"+i);
                }

            }
        };

        new Thread(task1).start();
        new Thread(task2).start();

        try {
            Thread.sleep(10001);
            System.out.println(count.size());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
